import { Request, Response, NextFunction } from "express";

export const errorHandler = (error: Error, _request: Request, response: Response, _next: NextFunction) => {
	if (error instanceof Error) {
		console.error(error.stack);
		if (error.message) response.statusMessage = error.message;
		response.json(null);
	} else {
		response.statusCode = 500;
		response.json(null);
	}
};
